# Contributor: Konstantin Kulikov <k.kulikov2@gmail.com>
# Maintainer: Konstantin Kulikov <k.kulikov2@gmail.com>
pkgname=mtg
pkgver=2.1.6
pkgrel=2
pkgdesc="MTPROTO proxy for Telegram"
url="https://github.com/9seconds/mtg"
license="MIT"
arch="all !x86 !armhf !armv7" # 32bit archs seem broken
makedepends="go"
options="net"
subpackages="$pkgname-openrc"
install="mtg.pre-install"
source="$pkgname-$pkgver.tar.gz::https://github.com/9seconds/mtg/archive/refs/tags/v$pkgver.tar.gz
	mtg.initd
	mtg.confd
	mtg.conf
	skip-network-tests.patch
	increase-test-timeout.patch
	"
export GOPATH=$srcdir/go
export GOCACHE=$srcdir/go-build
export GOTMPDIR=$srcdir
export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	go build -v .
}

check() {
	go test ./...
}

package() {
	install -Dm755 $builddir/mtg $pkgdir/usr/sbin/mtg
	install -Dm755 $srcdir/$pkgname.initd $pkgdir/etc/init.d/$pkgname
	install -Dm644 $srcdir/$pkgname.confd $pkgdir/etc/conf.d/$pkgname
	install -Dm644 $srcdir/$pkgname.conf  $pkgdir/etc/$pkgname.conf
}

sha512sums="
2ae18d839be736d2ed0b16310a22aad5d98818f83b64730199ad7738055626bcaa7a29aa5aaeb1a65d128b791ebd5b950e4b8838cbba8253d1f74222cacc7d15  mtg-2.1.6.tar.gz
6ce0b34b2224ea86d56f1c6911302c42a6b4aa9d13046fd0016d9adc267121fd1365829e26559875b836d0b94f9e784954949094489b7e16975d82332d241273  mtg.initd
41c3edc721fae9569596776e38fe6cebfe213cbb62b9a187fbb893eab9421d64ec5a683a54af5f1444a3e28af89402ab4d55abf9f653a64a040c0a4b684f5ece  mtg.confd
340651372d8fa861bf40ead66af7fc52ee917aa62eb21bbf562bd5775ffd13ed688fe516a278aa96a8fe55ea48225ca1d9048a7bca7eaf6a5fedd563b27f21b4  mtg.conf
affffba79e839030482c904cd278977d380e5d5179d752c28ee923e69fa82bd09458517d851c943fa7ffe121811c663c2dc6b692c34b3a2c6e28ab4284eac11d  skip-network-tests.patch
70eef96edf5298da0d1b6540ecf31253f0b5cfbe443b77f0b7f601051d9e6060f15afc29ecd0de92db3b7e8e0cbcd055b30b3b990b4202da546a798db4c48e7a  increase-test-timeout.patch
"
